import java.util.Scanner;
public class test {
    public static void main(String[] args){
        test0[] arr = new test0[3];
        Scanner sr = new Scanner(System.in);
        int j = 0;
        for (;j<arr.length;j++){
            while(true) {
                test0 t = new test0();
                System.out.println("请输入第"+(j+1)+"个学生的学号");
                int id = sr.nextInt();
                if (judge(arr, j, id)){
                    t.setId(id);
                    System.out.println("请输入第"+(j+1)+"个学生的姓名");
                    String name =sr.next();
                    t.setName(name);
                    System.out.println("请输入第"+(j+1)+"个学生的年龄");
                    int age = sr.nextInt();
                    t.setAge(age);
                    arr[j] = t;
                    break;
                }else{
                    System.out.println("输入学号重复请重新输入");
                }
            }
        }
        //遍历所有学生信息
        for(int i = 0;i<arr.length;i++){
            if (arr[i] == null){
            }else{
                System.out.println(arr[i].getId()+" "+arr[i].getName()+" "+arr[i].getAge());
            }
        }
    }
    //创建方法判断id是否重复
    public static boolean judge(test0[]arr,int j,int id){
        for (int e=0;e<j;e++){
            test0 t=arr[e];
            if(id==t.getId()){
                return false;
            }
        }
        return true;
    }
}
